home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / xman / man.h < prev    next >
C/C++ Source or Header  |  1994-09-27  |  7KB  |  249 lines

  1. /*
  2.  * xman - X window system manual page display program.
  3.  *
  4.  * $XConsortium: man.h,v 1.29 91/07/10 10:41:54 dave Exp $
  5.  *
  6.  * Copyright 1987, 1988 Massachusetts Institute of Technology
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted, provided
  10.  * that the above copyright notice appear in all copies and that both that
  11.  * copyright notice and this permission notice appear in supporting
  12.  * documentation, and that the name of M.I.T. not be used in advertising or
  13.  * publicity pertaining to distribution of the software without specific,
  14.  * written prior permission.  M.I.T. makes no representations about the
  15.  * suitability of this software for any purpose.  It is provided "as is"
  16.  * without express or implied warranty.
  17.  *
  18.  * Author:    Chris D. Peterson, MIT Project Athena
  19.  * Created:   October 22, 1987
  20.  */
  21.  
  22. /* X toolkit header files */
  23.  
  24. #include <X11/Intrinsic.h>
  25. #include <X11/StringDefs.h>
  26. #include <X11/Shell.h>
  27.  
  28. #include <X11/Xaw/Cardinals.h>
  29.  
  30. /* Std system and C header files */
  31.  
  32. #include <stdio.h>
  33.  
  34. #include <X11/Xfuncs.h>
  35. #include <X11/Xos.h>
  36.  
  37. /* X include files */
  38.  
  39. #include <X11/Xatom.h>
  40.  
  41. /* Widget header files. */
  42.  
  43. #include <X11/Xaw/AsciiText.h>
  44. #include <X11/Xaw/SmeBSB.h>
  45. #include <X11/Xaw/Box.h>
  46. #include <X11/Xaw/Command.h>
  47. #include <X11/Xaw/Dialog.h>
  48. #include <X11/Xaw/Label.h>
  49. #include <X11/Xaw/List.h>
  50. #include <X11/Xaw/MenuButton.h>
  51. #include <X11/Xaw/SimpleMenu.h>
  52. #include <X11/Xaw/Paned.h>
  53. #include <X11/Xaw/Viewport.h>
  54.  
  55. /* program specific header files. */
  56.  
  57. #include "ScrollByL.h"
  58.  
  59. #include "version.h"
  60. #include "defs.h"
  61.  
  62. typedef void (*fcall)();    /* function pointer typedef */
  63.  
  64. /* 
  65.  * Assigning values here allows the user of Bitwise Or.
  66.  */
  67.  
  68. typedef struct _XmanFonts {
  69.   XFontStruct * directory;        /* The font for the directory.  */
  70. } XmanFonts;
  71.  
  72. typedef struct _XmanCursors {
  73.   Cursor top,            /* The top Cursor, default for xman. */
  74.     help,            /* The top cursor for the help menu. */
  75.     manpage,            /* The cursor for the Manpage. */
  76.     search_entry;        /* The cursor for the text widget in the
  77.                    search box.*/
  78.   Pixel fg_color;        /* foreground color of cursors. */
  79.   Pixel bg_color;        /* background color of cursors. */
  80. } XmanCursors;
  81.  
  82. typedef struct _ManPageWidgets {
  83.   Widget manpage,        /* The manual page window (scrolled) */
  84.     directory,            /* The widget in which all directories will
  85.                    appear. */
  86.     *box;            /* The boxes containing the sections. */
  87. } ManPageWidgets;
  88.  
  89. typedef struct _MenuStruct {
  90.   caddr_t data;
  91.   int number;
  92.   XrmQuark quark;
  93. } MenuStruct;
  94.  
  95. /*
  96.  * The manual sections and entries
  97.  */
  98.  
  99. typedef struct tManual {
  100.   char * blabel;        /* The button label. */
  101.   char ** entries;         /* The individual man page file names. */
  102.   char ** entries_less_paths;   /* Entry names only */
  103.   int nentries;            /* how many (TOTAL)*/
  104.   int nalloc;            /* how much space allocated */
  105.   int flags;            /* suffix, fold */
  106. } Manual;
  107.    
  108. /* psuedo Globals that are specific to each manpage created. */
  109.  
  110. typedef struct _ManpageGlobals{
  111.   int current_directory;    /* The directory currently being shown 
  112.                    on this manpage. */
  113.   Boolean dir_shown,        /* True if the directory is then current
  114.                    visable screen */
  115.     both_shown;            /* If true then both the manpage and
  116.                    the directory are to be shown.*/
  117.   Widget label,            /* The label widget at the top of the page. */
  118.     standby,            /* The please standby widget. */
  119.     save,            /* The "would you like to save?" widget. */
  120.     search_widget,        /* The search widget popup. */
  121.     help_button,        /* The help button. */
  122.     option_menu,        /* The option menu. */
  123.     text_widget;        /* text widget containing search string. */
  124.  
  125.   /* Widgets (Objects really) for the command menu entries. */
  126.  
  127.   Widget dir_entry, manpage_entry, help_entry,
  128.     search_entry, both_screens_entry, remove_entry, open_entry,
  129.     version_entry, quit_entry;
  130.  
  131.   char manpage_title[80];       /* The label to use for the current manpage. */
  132.  
  133.   char save_file[80];        /* the name of the file to save fomatted 
  134.                    page into. */
  135.   char tmpfile[80];        /* the name of the file to copy the formatted
  136.                    page from. */
  137.   Boolean compress;        /* Compress file on save? */
  138.   char ** section_name;        /* The name of each of the sections */
  139.  
  140.   ManPageWidgets manpagewidgets; /* The manpage widgets. */
  141.  
  142.   /* Things to remember when cleaning up whne killing manpage. */
  143.  
  144.   Widget This_Manpage;        /* a pointer to the root of
  145.                    this manpage. */
  146.  
  147. } ManpageGlobals;
  148.  
  149.  
  150. /* Resource manager sets these. */
  151.  
  152. typedef struct _Xman_Resources {
  153.   XmanFonts fonts;        /* The fonts used for the man pages. */
  154.   XmanCursors cursors;        /* The cursors for xman. */
  155.   Boolean show_help_syntax;    /* True of syntax message should be dumped to
  156.                    stdout. */
  157.   Boolean both_shown_initial;    /* The initial state of the manual pages
  158.                    show two screens or only one. */
  159.   Boolean top_box_active;    /* Put up the Top Box. */
  160.   Boolean clear_search_string;    /* clear the search string each time it
  161.                    is popped down? */
  162.   int directory_height;            /* The default height of directory in 
  163.                    both_shown mode. */
  164.   char * help_file;        /* The name of the help file. */
  165.   char * title;                    /* The title for topBox */
  166.   Boolean iconic;        /* Should topBox come up in an iconic state */
  167. } Xman_Resources;
  168.  
  169. /************************************************************
  170.  *
  171.  * Function Defintions 
  172.  * 
  173.  ************************************************************/
  174.  
  175. /*
  176.  * This is easier than trying to find all calls to StrAlloc().
  177.  */
  178.  
  179. #define StrAlloc(ptr) XtNewString(ptr)
  180.  
  181. /* Standard library function definitions. */
  182.  
  183. #ifndef X_NOT_STDC_ENV
  184. #include <stdlib.h>
  185. #else
  186. char *getenv(), *malloc(), *realloc();
  187. void exit();
  188. #endif
  189.  
  190. /* Toolkit standard definitions. */
  191.  
  192. void XtResizeWidget(), XtMoveWidget();
  193.  
  194. /* buttons.c */
  195.  
  196. void MakeTopBox(), FormUpWidgets();
  197. void CreateManpageWidget(), MakeSaveWidgets(), WriteLabel();
  198. void MakeTopPopUpWidget(),MakeDirPopUpWidget(), MakeDirectoryBox();
  199. char * CreateManpageName();
  200. Widget CreateManpage();
  201.  
  202. /* handler.c */
  203.  
  204. void DirectoryHandler(), PopUpMenu(), SaveCallback(), OptionCallback();
  205. void Popup(),ManpageButtonPress(), GotoManpage(), DirPopupCallback();
  206.  
  207. /* Action Routines. */
  208.  
  209. void GotoPage(), PopupHelp(), PopupSearch(), Quit(), SaveFormattedPage();
  210. void CreateNewManpage(), RemoveThisManpage(), Search(), ShowVersion();
  211.  
  212. /* help.c */
  213.  
  214. Boolean MakeHelpWidget(), OpenHelpfile();
  215.  
  216. /* main.c */
  217.  
  218. void main();
  219.  
  220. /* man.c */
  221.  
  222. int Man();
  223.  
  224. /* misc.c */
  225.  
  226. void PrintError(),PrintWarning(), PopupWarning(), ChangeLabel(), OpenFile();
  227. void RemovePixmaps(),PositionCenter(),AddCursor(),ParseEntry();
  228. FILE *FindManualFile(),*Format(), *OpenEntryFile();
  229. ManpageGlobals * GetGlobals();
  230. void SaveGlobals(), RemoveGlobals();
  231.  
  232. /* pages.c */
  233.  
  234. Boolean InitManpage();
  235. void PrintManpage();
  236. Boolean Boldify();
  237.  
  238. /* search */
  239.  
  240. void MakeSearchWidget();
  241. FILE * DoSearch();
  242.  
  243. /* tkfunctions.c */
  244.  
  245. int Width(), Height(), BorderWidth();
  246. Widget PopupChild(), Child();
  247. char * Name();
  248. Boolean MakeLong();
  249.